Dictionary style headers

Dictionaries and concordances usually have a header containing the first word defined on the page or both the first and the last words. This can easily be accomplished with fancyheadings and 's mark mechanism. Of course if you use the marks for dictionary style headers, you cannot use them for chapter and section information, so if there are also chapters and sections present, you must redefine the \chaptermark and \sectionmark to make them harmless:

\renewcommand{\chaptermark}[1]{}
\renewcommand{\sectionmark}[1]{}

Now you do a \markboth{#1}{#1} for each dictionary or concordance entry #1 and use \rightmark for the first entry defined on the page and \leftmark for the last one.

If you want to use a header entry of the form firstword–lastword it would be nice if this would be reduced to just the form firstword if both are the same. This could happen if there is just one entry on the page. In this case a test must be made to check if the marks are the same. However, /'s marks are strange beasts, which cannot be compared out of the box with the plain / \if commands. Fortunately the ifthen package works well:

\newcommand{\mymarks}{
  \ifthenelse{\equal{\leftmark}{\rightmark}}
    {\rightmark}
    {\rightmark--\leftmark}}
\lhead[\rm \mymarks]{\rm \thepage}
\rhead[\rm \thepage]{\rm \mymarks}

Dictionaries are often done with two columns. Unfortunately there is a bug in 's twocolumn option which causes some marks to be lost. If you use the package in figure [*], this will be solved34.

Figure: Fix marks in twocolumn style
\begin{figure}\small
\index{fixmarks.sty@\texttt{fixmarks.sty}}
\begin{verbatim}...
...fi{\@outputpage\@startdblcolumn}\endgroup
\fi}\end{verbatim}
\par\end{figure}